home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00030_Repeating Button Class.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  922 b   |  40 lines

  1. property channel, buttonOut, buttonIn, repeatDelay, commandString, feedback
  2. global gButton
  3.  
  4. on birth me, message, repeatSteps
  5.   set commandString to message
  6.   do("set feedback =" & commandString)
  7.   if feedback = 1 then
  8.     set state to #pressed
  9.     set channel to the clickOn
  10.     set buttonOut to the castNum of sprite channel
  11.     set buttonIn to buttonOut + 1
  12.     set gButton to me
  13.     set the castNum of sprite channel to buttonIn
  14.     puppetSprite(channel, 1)
  15.     set repeatDelay to repeatSteps
  16.     add(the actorList, me)
  17.   end if
  18. end
  19.  
  20. on stepFrame me
  21.   if the mouseDown then
  22.     if repeatDelay > 0 then
  23.       set repeatDelay to repeatDelay - 1
  24.     else
  25.       do("set feedback =" & commandString)
  26.       if feedback = 0 then
  27.         death(me)
  28.       end if
  29.     end if
  30.   else
  31.     death(me)
  32.   end if
  33. end
  34.  
  35. on death me
  36.   puppetSprite(channel, 0)
  37.   deleteAt(the actorList, getPos(the actorList, me))
  38.   set gButton to EMPTY
  39. end
  40.